const fs = require('fs')
const HomeData = require('./db/schema/home');//引入schema
const Goods = require('./db/schema/goods');//引入schema

function importData(path, schemeClass) {
  let data = fs.readFileSync(path, 'utf8');
  data = JSON.parse(data);
  data.map(item => {
    const scheme = new schemeClass(item);
    return scheme.save();
  });
} 

Promise.all(Array.prototype.concat.call([], importData('./mockData/homeGoods.json', HomeData), importData('./mockData/goods.json', Goods))).then(() => {
  console.log('导入数据完毕!');
});